<!--
 * @Descripttion: 
 * @Author: voanit
 * @Date: 2022-08-24 14:39:04
 * @LastEditors: voanit
 * @LastEditTime: 2022-08-24 14:43:31
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const sum = (n) => {
      /* 
      1-需要return  断开
      2-需要求和  sum()
      */
      if (n == 1) return 1
      return sum(n - 1) + n
    }

    console.log(sum(10));
  </script>
</body>

</html>